{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "5092516e-2b79-4681-b220-d0d472e8b3d6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "maman! whwhat can i say\n"
     ]
    }
   ],
   "source": [
    "print(\"maman! whwhat can i say\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "9cce9241-9260-4b17-92ef-1682521055ff",
   "metadata": {},
   "outputs": [],
   "source": [
    "def funss(s):\n",
    "    r = \"\"\n",
    "    for i in s:\n",
    "        if i.isupper():\n",
    "            r += \" \"\n",
    "        r += i\n",
    "    return r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "518adaf0-5176-4f1c-a5e3-bcc0b0f3431b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'man What Can I Say'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "funss(\"manWhatCanISay\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "ff1cf7e6-1e40-4466-bc92-04fb621d6585",
   "metadata": {},
   "outputs": [],
   "source": [
    "def funss2(s):\n",
    "    return \"\".join([\" \"+i if i.isupper() else i for i in s])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "051c7968-b3da-4f39-acae-b22d53d1911e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'man What Can I Say'"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "funss2(\"manWhatCanISay\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "042b35ae-de74-4378-84ad-c126fad10321",
   "metadata": {},
   "outputs": [],
   "source": [
    "funss3 = lambda s : \"\".join([\" \"+i if i.isupper() else i for i in s])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "d7c0dcc2-911a-4d0b-bb29-b832c2a09737",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'man What Can I Say'"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "funss3(\"manWhatCanISay\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5e8cf092-caac-4b05-bba4-9b4a5f06bb11",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "fbd0c377-b8de-4910-832c-65ff838bc00d",
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('testin.txt', \"r\") as f:\n",
    "    txt = f.readlines()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "98262038-075b-49d3-a260-80efba18c63c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'list'>\n",
      "46\n"
     ]
    }
   ],
   "source": [
    "print(type(txt))\n",
    "print(len(txt))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "1f24849f-c632-405d-b45c-9e6b301760d6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "BRC\tVARCHAR2(9)\n",
      "\n",
      "TRANDATE\tDATE\n",
      "\n",
      "ACQSERSTAN\tNUMBER\n",
      "\n",
      "CLEARSERSTAN\tNUMBER\n",
      "\n",
      "TRANSEQNO\tNUMBER\n",
      "\n",
      "CURRENCY\tVARCHAR2(3)\n",
      "\n",
      "COMMITWAY\tVARCHAR2(1)\n",
      "\n",
      "\tVARCHAR2(2)\n",
      "\n",
      "BILLKIND\tVARCHAR2(2)\n",
      "\n",
      "BILLNO\tVARCHAR2(20)\n",
      "\n",
      "COMMITVOUNO\tVARCHAR2(9)\n",
      "\n",
      "COMMITAMT\tNUMBER(16,2)\n",
      "\n",
      "PAYMENTAMT\tNUMBER(16,2)\n",
      "\n",
      "FINE\tNUMBER(16,2)\n",
      "\n",
      "RECVBANKNO\tVARCHAR2(12)\n",
      "\n",
      "RECVBANKISNAME\tVARCHAR2(60)\n",
      "\n",
      "RECVACCNO\tVARCHAR2(32)\n",
      "\n",
      "RECVACCISNAME\tVARCHAR2(60)\n",
      "\n",
      "PAYBANKNO\tVARCHAR2(12)\n",
      "\n",
      "PAYBANKISNAME\tVARCHAR2(60)\n",
      "\n",
      "PAYACCNO\tVARCHAR2(32)\n",
      "\n",
      "PAYACCISNAME\tVARCHAR2(60)\n",
      "\n",
      "SIGNDATE\tDATE\n",
      "\n",
      "ENDDATE\tDATE\n",
      "\n",
      "ACCEPTDATE\tDATE\n",
      "\n",
      "SQUAREDATE\tDATE\n",
      "\n",
      "REPORTNO\tVARCHAR2(12)\n",
      "\n",
      "POSTSHEETNUM\tNUMBER\n",
      "\n",
      "RECEICEDSHEETNUM\tNUMBER\n",
      "\n",
      "MEMO\tVARCHAR2(60)\n",
      "\n",
      "OVERPAYREASON\tVARCHAR2(60)\n",
      "\n",
      "REFUSEPAYREASON\tVARCHAR2(60)\n",
      "\n",
      "COMMITKIND\tVARCHAR2(1)\n",
      "\n",
      "GOODSTRANSPSTATUS\tVARCHAR2(60)\n",
      "\n",
      "CONTRACTISNAME\tVARCHAR2(60)\n",
      "\n",
      "CONTRACTNO\tVARCHAR2(9)\n",
      "\n",
      "TELLER\tVARCHAR2(6)\n",
      "\n",
      "RTELLER\tVARCHAR2(6)\n",
      "\n",
      "CTELLER\tVARCHAR2(6)\n",
      "\n",
      "FLAG\tVARCHAR2(1)\n",
      "\n",
      "PAYWAY\tVARCHAR2(1)\n",
      "\n",
      "STATUS\tVARCHAR2(1)\n",
      "\n",
      "ODS_DATA_DT\tVARCHAR2(8)\n",
      "\n",
      "ODS_PK_MD5\tVARCHAR2(32)\n",
      "\n",
      "ODS_CMP_COL_MD5\tVARCHAR2(32)\n",
      "\n",
      "ODS_FLG\tVARCHAR2(1)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "for i in txt:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "a19962e2-e2c9-42b1-9c6a-be709d7c315c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      ",BRC\tVARCHAR2(9)\n",
      "\n",
      ",TRANDATE\tDATE\n",
      "\n",
      ",ACQSERSTAN\tNUMBER\n",
      "\n",
      ",CLEARSERSTAN\tNUMBER\n",
      "\n",
      ",TRANSEQNO\tNUMBER\n",
      "\n",
      ",CURRENCY\tVARCHAR2(3)\n",
      "\n",
      ",COMMITWAY\tVARCHAR2(1)\n",
      "\n",
      ",\tVARCHAR2(2)\n",
      "\n",
      ",BILLKIND\tVARCHAR2(2)\n",
      "\n",
      ",BILLNO\tVARCHAR2(20)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "for i in txt[:10]:\n",
    "    print(\",\"+i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "432e1f59-ad88-4164-8225-17eb274cdc9f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "97\n"
     ]
    }
   ],
   "source": [
    "print(len(txt2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "9b866ead-3dc1-4f02-93c7-39c165f19b8b",
   "metadata": {},
   "outputs": [],
   "source": [
    "txt2 = [\"\\n\" + txt[0]] + [\",\"+i for i in txt[1:]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "60c0838f-6973-4365-9a9b-e64924b0180f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "46\n"
     ]
    }
   ],
   "source": [
    "print(len(txt2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "0db4c709-5a08-45d9-863f-016701e58948",
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(\"testout.txt\", \"w\") as f:\n",
    "    f.write(\"create table xxxx(\")\n",
    "    f.writelines(txt2)\n",
    "    f.write(\");\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "f863be44-c35c-4f4f-9d75-4add974653ac",
   "metadata": {},
   "outputs": [],
   "source": [
    "def ctxx(name):\n",
    "    with open('testin.txt', \"r\") as f:\n",
    "        txt = f.readlines()\n",
    "    txt2 = [\"\\n\" + txt[0]] + [\",\"+i for i in txt[1:]]\n",
    "    with open(\"testout.txt\", \"w\") as f:\n",
    "        f.write(f\"create table p1_{name}(\")\n",
    "        f.writelines(txt2)\n",
    "        f.write(\");\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "30f4f33f-49d6-4c2e-86e9-e238c76c2a6e",
   "metadata": {},
   "outputs": [],
   "source": [
    "def ctxx(name):\n",
    "    with open('testin.txt', \"r\") as f:\n",
    "        txt = f.readlines()\n",
    "    txt2 = [i.strip()+\"   \" + \"varchar2(30), \\n\" for i in txt]\n",
    "    with open(\"testout.txt\", \"w\") as f:\n",
    "        f.write(f\"create table p1_{name}(\\n\")\n",
    "        f.writelines(txt2)\n",
    "        f.write(\");\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "dd54a75d-df40-4b3e-948e-6fc6d5c1c72c",
   "metadata": {},
   "outputs": [],
   "source": [
    "def ctxx(name):\n",
    "    with open('testin.txt', \"r\") as f:\n",
    "        txt = f.readlines()\n",
    "    txt2 = []\n",
    "    for i in txt:\n",
    "        m = i.split()\n",
    "        if m[1] == \"d\":\n",
    "            txt2.append(m[0]+\"   date,\\n\")\n",
    "        elif m[1] == \"n\":\n",
    "            txt2.append(m[0]+\"   number,\\n\")\n",
    "        else:\n",
    "            txt2.append(m[0]+\"   varchar2(30),\\n\")\n",
    "    with open(\"testout.txt\", \"w\") as f:\n",
    "        f.write(f\"create table p1_{name}(\\n\")\n",
    "        f.writelines(txt2)\n",
    "        f.write(\");\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "58bc3715-ddc3-4b10-a50a-160b4eec36da",
   "metadata": {},
   "outputs": [],
   "source": [
    "ctxx(\"O_CBS_PUBCOUNTRYINFO\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "84416443-0b9c-4f4c-970d-57f0c680f571",
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('testin.txt', \"r\", encoding='utf-8') as f:\n",
    "        txt = f.readlines()   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "259beb3a-a235-46e2-a661-52e805ae9e89",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "29\n"
     ]
    }
   ],
   "source": [
    "print(len(txt))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "aaa11a6f-33a7-4f08-9145-8942aa7cdce0",
   "metadata": {},
   "outputs": [],
   "source": [
    "from random import randint as rd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "6c88c978-627c-48a7-a726-1a0f94e013af",
   "metadata": {},
   "outputs": [],
   "source": [
    "txt2 = []\n",
    "for i in txt:\n",
    "    s = ''\n",
    "    for j in i:\n",
    "        if j.isdigit() or j == \".\":\n",
    "            s += j\n",
    "        else:\n",
    "            continue\n",
    "    if s[-1] == \".\":\n",
    "        txt2.append('t_' + s[:-1] +\"   number,\\n\")\n",
    "    else:\n",
    "        txt2.append('t_' + s +\" number,\\n\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "14db84fc-0edf-4c02-9925-939ce7c76281",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['t_1   number,\\n', 't_2   number,\\n', 't_2.1 number,\\n', 't_2.2 number,\\n', 't_2.3 number,\\n', 't_2.4 number,\\n', 't_2.5 number,\\n', 't_2.6 number,\\n', 't_2.7 number,\\n', 't_2.8 number,\\n', 't_2.9 number,\\n', 't_2.10 number,\\n', 't_2.11 number,\\n', 't_2.12 number,\\n', 't_2.13 number,\\n', 't_2.14 number,\\n', 't_2.15 number,\\n', 't_2.16 number,\\n', 't_2.17 number,\\n', 't_2.18 number,\\n', 't_2.19 number,\\n', 't_2.20 number,\\n', 't_2.21 number,\\n', 't_2.21.1 number,\\n', 't_2.21.2 number,\\n', 't_2.21.3 number,\\n', 't_2.21.4 number,\\n', 't_2.22 number,\\n', 't_3   number,\\n']\n"
     ]
    }
   ],
   "source": [
    "print(txt2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "41be9f87-254d-4d9f-bfd5-a61f2ba0a1be",
   "metadata": {},
   "outputs": [],
   "source": [
    "def ctxx(name):\n",
    "    with open('testin.txt', \"r\", encoding='utf-8') as f:\n",
    "        txt = f.readlines()   \n",
    "    txt2 = []\n",
    "    for i in txt:\n",
    "        s = ''\n",
    "        for j in i:\n",
    "            if j.isdigit() or j == \".\":\n",
    "                s += j\n",
    "            else:\n",
    "                continue\n",
    "        txt2.append('t_' + s.replace('.','') +\"   number,\\n\")\n",
    "    with open(\"testout.txt\", \"w\") as f:\n",
    "        f.write(f\"create table demo_{name}(\\n\")\n",
    "        f.writelines(txt2)\n",
    "        f.write(\");\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "a54d5c3b-98e2-4e8e-a9e1-e5fc1c57ac77",
   "metadata": {},
   "outputs": [],
   "source": [
    "ctxx(\"G01_1\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "016ffacd-87d5-4279-9b09-230938a163a5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[71.87, 74.26, 88.38, 33.88, 59.71, 31.85, 39.95, 77.43, 73.27, 94.04, 77.95, 64.65, 77.23, 83.75, 45.28, 51.04, 82.17, 86.62, 45.99, 76.28, 67.59, 40.84, 70.44, 90.38, 46.0, 81.84, 54.51, 60.14, 41.42, 90.23, 50.91, 100.86, 95.72, 42.28, 42.47, 33.72, 61.68, 87.75, 57.18, 49.0, 84.32, 66.15, 94.32, 71.64, 56.22, 60.6, 44.74, 57.76, 33.78, 45.57, 37.19, 83.84, 37.48, 84.91]\n"
     ]
    }
   ],
   "source": [
    "print([rd(30,100)+(rd(0,100)/100) for _ in range(54)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "0cf6b5a3-5670-46fe-8046-bae4327dca1f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "54"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len((75, 93, 46, 46, 85, 98, 51, 94, 61, 90, 36, 84, 41, 40, 93, 81, 57, 31, 36, 100, 59, 62, 40, 91, 33, 99, 87, 55,\n",
    " 69, 90, 98, 93, 70, 82, 33, 69, 84, 86, 41, 60, 76, 32, 33, 75, 68, 39, 45, 35, 63, 52, 48, 78, 49, 61))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8ae0e896-13b2-420f-a56f-f8825bb1fd89",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "c67e6273-ee01-409c-897c-ecfd0abfbdfc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "57"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rd(30,60)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f837d50f-a8e7-4f3a-a148-fd1effbefd40",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "017e706b-b9c9-4a5d-b091-ac464761cf34",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "626b786f-36e8-4e2f-ab0f-40ab53a4e1a9",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "783d2c0b-5830-4ef8-9477-5267312cb656",
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('testin.txt', \"r\") as f:\n",
    "        txt = f.readlines()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "8d964324-09aa-4d29-8914-a88f130501bb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['crdt_ln_cntrct_no', 'v']\n",
      "['cust_cd', 'n']\n",
      "['crdt_ln_pd_cd', 'n']\n",
      "['ccy_cd', 'v']\n",
      "['insrnc_brc', 'v']\n",
      "['fund_src_tp', 'd']\n",
      "['ln_use_dscptn', 'd']\n",
      "['bnchmrk_rate', 'v']\n"
     ]
    }
   ],
   "source": [
    "for i in txt:\n",
    "    print(i.split())\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "db595158-4fbb-4ec1-9862-2ec9fb11a55c",
   "metadata": {},
   "outputs": [],
   "source": [
    "txt2 = []\n",
    "for i in txt:\n",
    "    m = i.split()\n",
    "    if m[1] == \"d\":\n",
    "        txt2.append(m[0]+\"   date,\")\n",
    "    elif m[1] == \"n\":\n",
    "        txt2.append(m[0]+\"   number,\")\n",
    "    else:\n",
    "        txt2.append(m[0]+\"   varchar2(30),\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "5e601cb5-1eef-4432-92eb-9cda9aed9c6b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['crdt_ln_cntrct_no   varchar2(30),',\n",
       " 'cust_cd   number,',\n",
       " 'crdt_ln_pd_cd   number,',\n",
       " 'ccy_cd   varchar2(30),',\n",
       " 'insrnc_brc   varchar2(30),',\n",
       " 'fund_src_tp   date,',\n",
       " 'ln_use_dscptn   date,',\n",
       " 'bnchmrk_rate   varchar2(30),']"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e60004f5-10c8-4a81-ad2c-9c884407f24e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ec765dc7-bf71-433e-bdac-51f6eba68c0f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d6273ced-d44e-4336-bd2d-6ac855bb6f4f",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
